<template>
	<view class="wrap">
		<view class="tips">
			登录密码请不要与支付密码或其他网站密码一致,由此产生的账号被盗,本站概不负责。

		</view>
		<view class="ipt-wrap name-wrap">
			<view class="label">
				原密码
			</view>
			<view class="right">
				 <input v-model="old_pwd"  type="password" placeholder="请输入原密码" />
			</view>
		</view>
		
		<view class="ipt-wrap">
			<view class="label">
				新密码
			</view>
			<view class="right">
				 <input v-model="new_pwd"  type="password" placeholder="请设置新的登录密码" />
			</view>
		</view>
		<view class="ipt-wrap">
			<view class="label">
				确认密码
			</view>
			<view class="right">
				 <input v-model="repeat_pwd"  type="password" placeholder="请确认新的登录密码" />
			</view>
		</view>
		<view class="next" @click="subData">
			确认修改
		</view>
		<view class="forget" @click="enterpage('../forget/index')">
			<text>忘记密码？</text>
		</view>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				old_pwd:'',
				new_pwd:'',
				repeat_pwd: ''
			}
		},
		onLoad() {

		},
		methods: {
			subData(){
				let that=this
				if(this.old_pwd==''){
					uni.showToast({
					    title: '请输入原密码',
					   duration:4000,
						icon:'none'
					});
					return
				}
				if(this.new_pwd==''){
					uni.showToast({
					    title: '请设置新的登陆密码',
					    duration:4000,
						icon:'none'
					});
					return
				}
				if(this.new_pwd!=this.repeat_pwd){
					uni.showToast({
					    title: '两次输入密码不一致',
					    duration:4000,
						icon:'none'
					});
					return
				}
				that.apipost('/api/user/change_pwd',{
					repeat_pwd:that.repeat_pwd,
					old_pwd:that.old_pwd,
					new_pwd:that.new_pwd
				},true).then(res => {
					if(res.Code==10200){
						uni.showToast({
						    title: '密码修改成功',
						    duration:4000,
							icon:'none'
						});
						uni.switchTab({
						    url: '/pages/login/index'
						});
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			enterpage(path){
				if(path){
					uni.navigateTo({
					    url: path
					});
				}else{
					uni.showToast({
					    title: '暂未开放',
					    duration:4000,
						icon:'none'
					});
				}
			}
		}
	}
</script>

<style>
	.forget{
		display:flex;
		justify-content: flex-end;
		padding-top:20rpx;
		color:#1380db;
		width:640rpx;
		margin:0 auto;
	}
	.next{
		
		background:#f9436b;
		color:#fff;
		width:640rpx;
		margin:0 auto;
		display:flex;
		justify-content: center;
		align-items: center;
		height:80rpx;
		margin-top:60rpx;
		border-radius:12rpx;
	}
	.ipt-wrap .label{
		width:200rpx;
	}
	.right input{
		height:100%;
	}
	.ipt-wrap{
		display:flex;
		align-items: center;
		width:640rpx;
		margin:0 auto;
		margin-top:30rpx;
		padding:26rpx 0;
		border-bottom:1rpx solid #e8e8e8
	}

	/* .name-wrap{
		border-bottom:1rpx solid #e8e8e8
	} */
	.wrap{
		background:#fbfbfb;
		min-height:100%;
	}
	.tips{
		color:#333;
		line-height:70rpx;
		background:#eeeeee;
		padding:34rpx 44rpx 34rpx 30rpx;
	}
</style>
